-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
sphinx_highlight.js: remove ?highlight= query param handling
#13921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
* Do not use `?highlight=` query param as a fallback for search
highlighting. All major browsers support `#:~:text=` natively now, and
Sphinx does not link from search results with `?highlight=` URLs, it
only uses `localStorage`.
* Simplify `document.querySelectorAll("div.body")[0]` to
`document.querySelector("div.body")`
* Simplify `document.querySelector("body")` with `document.body`
* Replace `setTimeout` with `requestAnimationFrame`
?highlight= query param handling
Use Sphinx 8.2.3 with this patch: sphinx-doc/sphinx#13921, so that it's easier to link particular paragraphs in the text using Text Fragments.
Use Sphinx 8.2.3 with this patch: sphinx-doc/sphinx#13921, so that it's easier to link particular paragraphs in the text using Text Fragments. Signed-off-by: Harmen Stoppels <[email protected]>
It depends on what you mean by "use". It supports them in so far as if you append It doesn't "use" it in so far as it doesn't show URLs with Until a few years ago, it was added to the URL, and I made a PR for it to be removed when clicking "Hide Search Matches": #9551. Some people didn't like that I still think that this was a mistake and that removing
I don't think it is a decent replacement, since it only highlights the first occurrence, while |
So, If it's for sharing links, then I would argue That to me suggests there's not a good reason to keep the feature. |
Closes #13916
Alternative to #13918
?highlight=query param as a (manual) fallback for search highlighting.While at it:
document.querySelectorAll("div.body")[0]todocument.querySelector("div.body")document.querySelector("body")withdocument.bodysetTimeoutwithrequestAnimationFramePurpose
This PR removes the
?highlight=related code, for two reasons:?highlight=links internally.#:~:text=...is a decent replacement for?highlight=...for adding highlighting manually.window.history.replaceStateunconditionally. This has an unpleasant side effect: it removes#:~:text=...fragments from the URL, making it hard to purposefully share URLs that include highlighted text.References
<url>?highlight=search-termtolocalStorage.setItem("sphinx_highlight_terms", "search-term")to support highlighting of search terms on a page: Move to localStorage for search highlighting #10854?highlight=...URLs were still supported, cause you could add that manually.?highlight=...was to always remove?highlight=from the URL.sphinx_highlight.jsremoves text fragment from URL #13916window.history.replaceStateunconditionally #13918